<?php

namespace App\Models;

use Dcat\Admin\Traits\HasDateTimeFormatter;

use Illuminate\Database\Eloquent\Model;

class Article extends Model
{
	use HasDateTimeFormatter;
    protected $table = 'eb_article';
    protected $fillable = ['id', 'type','hospital_id','status','subject_pid','subject','is_push'];
    public $timestamps = false;

    public static $typeEnum = [
        '1' => '宣教指导',
        '2' => '普通文章',
        '3' => '社区通知',
        '4' => '系统文章',
    ];

    public function info(){
        return $this->hasOne(ArticleInfo::class,'article_id','id');
    }

    public function familyType(){
        return $this->belongsToMany(FamilyType::class,ArticleType::class,'article_id','family_type_id');
    }
    public function hospitals(){
        return $this->belongsToMany(Hospital::class, HospitalAdminUserHospital::class, 'hsopital_admin_users_id', 'hospital_id');
    }

    public function notice(){
        return $this->hasOne(Notice::class,'article_id','id');
    }
}
